<?php

namespace App\CustHub\Mapper;

use App\CustHub\Model\ChCustomerServiceLink;
use Mine\Abstracts\AbstractMapper;

class ChCustomerServiceLinkMapper extends AbstractMapper
{
    public function assignModel()
    {
        $this->model = ChCustomerServiceLink::class;
    }

    public function findByLink(mixed $link): object|null
    {
        return $this->model::where('link', $link)->first();
    }

    public function findByRobotIdAndUid(int $robotId, int $uid):object|null
    {

        return $this->model::where('uid', $uid)
            ->whereJsonContains('robot_ids', $robotId)
            ->first(); // 返回第一条匹配的记录或null
    }

    public function findById(int $id): object
    {
        return $this->model::where('id', $id)->first();
    }
}